﻿
@{
    ViewBag.Title = "待报价";
    Layout = "~/Views/Shared/_LayoutEasyUI.cshtml";
}

<table id="grid-list"> </table>

@section scripts{
    <script>
        $(function () {
            Grid.LoadData();

        });

        var Grid = {
            LoadData: function () {
                var url = "/Order/QuoteHistoryData";
                Grid.list = $("#grid-list").datagrid({
                    url: url,
                    title: '历史报价',
                    fit: true,
                    fitColumns: true,
                    singleSelect: false,
                    rownumbers: true,
                    nowrap: false,
                    striped: true, //隔行变色
                    columns: [[
                        { field: 'FOrderNo', title: '订单编号', width: 120, align: 'center' },
                        { field: 'FStoreName', title: '门店', width: 100, align: 'center' },
                        { field: 'FAddress', title: '联系地址', width: 100, align: 'center' },
                         { field: 'FIndex', title: '行号', width: 40, align: 'center' },
                        { field: 'FItemName', title: '产品名称', width: 100, align: 'center' },
                        { field: 'FGgModel', title: '规格型号', width: 100, align: 'center' },
                        { field: 'FQty', title: '数量', width: 40, align: 'center' },
                        { field: 'FWeight', title: '重量', width: 80, align: 'center' },
                        { field: 'FVolume', title: '体积', width: 80, align: 'center' },
                        { field: 'FBjPrice', title: '保价金额', width: 80, align: 'center' },
                        { field: 'FDt', title: '有无电梯', width: 80, align: 'center' },
                        { field: 'TranspPrice1', title: '报价(入户)', width: 80, align: 'center' },
                        { field: 'TranspPrice2', title: '报价(不入户)', width: 80, align: 'center' }
                    ]],
                    onLoadSuccess: onLoadSuccess
                });
            },
            Refresh: function () {
                Grid.list.datagrid('reload');
            }
        }

        function onLoadSuccess(data) {
            var _orderid;
            var _index = -1;
            var _rowspan = 0;
            for (var i = 0; i < data.rows.length; i++) {
                if (_orderid != data.rows[i].FOrderId) {
                    //合并；
                    if (_rowspan > 1) {
                        mergeCell(_index, _rowspan);
                    }
                    _orderid = data.rows[i].FOrderId;
                    _index = i;
                    _rowspan = 1;
                } else {
                    _rowspan = _rowspan + 1;
                }
            }
            if (_rowspan > 1) {
                mergeCell(_index, _rowspan);
            }
        }

        function mergeCell(_index, _rowspan) {
            $(Grid.list).datagrid('mergeCells', {
                index: _index,
                field: 'FOrderNo',
                rowspan: _rowspan
            }).datagrid('mergeCells', {
                index: _index,
                field: 'FStoreName',
                rowspan: _rowspan
            }).datagrid('mergeCells', {
                index: _index,
                field: 'FAddress',
                rowspan: _rowspan
            }).datagrid('mergeCells', {
                index: _index,
                field: 'TranspPrice1',
                rowspan: _rowspan
            }).datagrid('mergeCells', {
                index: _index,
                field: 'TranspPrice2',
                rowspan: _rowspan
            });
        }
    </script>
}